#include "header/ThreadPool.h"
#include "header/SimpleThreadFactory.h"

void workFunction(void *args) {
    int *value = static_cast<int *>(args);
    printf("Thread PID %ld Execute Task %d Address = %lld!\n", pthread_self(), *value, &value);
    usleep(1000 * 200);
}

void test01() {
    ThreadPool *pool = new ThreadPool(5, 3, 8, new queue<Task>(), new SimpleThreadFactory());

    for (int i = 0; i < 100; ++i) {
        int *value = new int(i);
        pool->submitTask(value, workFunction);
        usleep(1000 * 100);
    }

    sleep(5);
    pool->shutdown();
    delete pool;
}

int main() {
    test01();
    cout << "Hello World!" << endl;
    return 0;
}
